test:
  variables:
    POSTGRES_VERSION: 9.6.16
    POSTGRES_DB: test
    POSTGRES_USER: user
    POSTGRES_PASSWORD: testing-password
  services:
    - "postgres:${POSTGRES_VERSION}"
  stage: test
  image: gliderlabs/herokuish:latest
  needs: []
  script:
    - |
      if [ -z ${KUBERNETES_PORT+x} ]; then
        DB_HOST=postgres
      else
        DB_HOST=localhost
      fi
    - export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:5432/${POSTGRES_DB}"
    - cp -R . /tmp/app
    - /bin/herokuish buildpack test
  rules:
    - if: '$TEST_DISABLED'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
